<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class VendorProfile extends CI_Controller {

	public function index()
	{
		$data = $this->getProfile();
	
		$data = array(
			'name' => $data->Vendor_Name,
			'attention' => $data->Attention,
			'street' => $data->Street_Address,
			'city' => $data->City,
			'state' => $data->State,
			'zipCode' => $data->Zip_Code,
			'source' => $data->Vendor_Source,
			'website' => $data->Vendor_Website
		);
		
		$this->load->view('v_vendorprofile', $data);
	}

	public function getId()
	{
		$user_email = $this->session->userdata('useremail');
		$this->load->model('m_vendorprofile');
		$query = $this->m_vendorprofile->get_user_id($user_email);
		return $query->row()->userId;
	}

	public function getProfile()
	{
		$user_id = $this->getId();
		$this->load->model('m_vendorprofile');
		$query = $this->m_vendorprofile->get_profile($user_id);
		return $query->row();
	}

	public function edit_user()
	{
		$this->load->model('m_vendorprofile');
		$user_profile = array(
			'userId' => $this->getId(),
			'name' => $_POST['name'],
			'attention' => $_POST['attention'],
			'street' => $_POST['street'],
			'city' => $_POST['city'],
			'state' => $_POST['state'],
			'zipCode' => $_POST['zipCode'],
			'source' => $_POST['source'],
			'website' => $_POST['website']
		);
		
		$this->m_vendorprofile->update_user_profile($user_profile);

		$this->load->view('v_vendorprofile', $user_profile);
	}
}

/* End of file userprofile.php */
/* Location: ./application/controllers/userprofile.php */
